<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>科室列表</title>
    <link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/5.3.0/css/bootstrap.min.css" rel="stylesheet">
    <script src="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/5.3.0/js/bootstrap.bundle.min.js"></script>
    <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
    <link rel="stylesheet" href="/stylesheets/common.css">
    <style>
        .header {
            border-radius: 10px;
        }

        h3,
        p {
            margin-bottom: 0;
        }
    </style>
</head>

<body>
    <h4 class="text-center mt-3" style="color: black;">科室列表</h4>
    <div class="container">
        <div class="p-3 text-primary-emphasis bg-primary-subtle border border-primary-subtle rounded-3">
            <h5>智能导诊</h5>
            <p>依据您的发病部位和症状为您导诊科室</p>
        </div>
        <div class="branch-list mt-3">
            <h5 style="color: black; font-weight: bold;" class="m-4">专科</h5>
            <div class="header department-list">
                <div class="text-dark">
                    科室列表
                    <hr>
                </div>
                <div class="text-dark">
                    科室列表
                    <hr>
                </div>
            </div>
        </div>
        <script>
            getKS();
            function getKS() {
                $.ajax({
                    method: 'get',
                    url: 'http://localhost:3000/department/selectdepartmentfrombranch',
                    data: {
                        id: localStorage.getItem('fyid'),
                    },
                    success: function (data) {
                        console.log(data)
                        renderdepartmentOption(data.data);
                    },
                    error: function (e) {
                        console.log(JSON.stringify(e));
                    }
                })
            }

            function renderdepartmentOption(data) {
                let str = '';
                data.forEach(item => {
                    str += ` <div class="text-dark" ksid="${item.id}">
                        ${item.name}
                    <hr>
                </div>`
                });
                $(".department-list").html(str);
            }
        </script>
</body>

</html>